from datetime import datetime

from pydantic import Field
from typing import Optional, Annotated, List

from ...base import BaseApiListOut, BaseSchema, BaseApiOut


class CompanyBase(BaseSchema):
    code: Optional[str] = Field(None, description='商户编码')
    brand_id: Optional[int] = Field(None, description='品牌编码')
    salesman: Optional[str] = Field(None, description='业务员')
    name: Optional[str] = Field(None, description='商户名称')
    email: Optional[str] = Field(None, description='Email')
    country: Optional[str] = Field(None, description='国家')
    industry: Optional[str] = Field(None, description='行业')
    contacts_name: Optional[str] = Field(None, description='联系人')
    contacts_tell: Optional[str] = Field(None, description='联系电话')
    status: Optional[int] = Field(None, description='企业状态 0未启用 1已启用 2已禁用')


class CompanyCreate(CompanyBase):
    pass


class CompanyOem(BaseSchema):
    oem_status: Optional[int] = Field(None, description='OEM状态 0未启用 1已启用 2已禁用')
    domain: Optional[str] = Field(None, description='域名')
    logo: Optional[str] = Field(None, description='LOGO')
    domain_tile: Optional[str] = Field(None, description='域名显示标题')


class Company(CompanyBase, CompanyOem):
    id: Optional[int] = Field(0, description='自增ID')

    api_token: Optional[str] = Field(None, description='API Token')

    parent_id: Optional[int] = Field(None, description='PID')
    user_id: Optional[int] = Field(None, description='添加人')

    created_at: Annotated[Optional[datetime], Optional[str]] = None
    updated_at: Annotated[Optional[datetime], Optional[str]] = None


class CompanyOut(BaseApiOut):
    data: Annotated[Company, None] = None


class CompanyListOut(BaseApiListOut):
    data: Annotated[List[Company], None] = None
